package com.nine.pesys.model.service.impl;

import com.nine.pesys.base.BaseSupportImpl;
import com.nine.pesys.model.entity.Equipment;
import com.nine.pesys.model.service.EquipmentService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by L先森 on 2014/12/23.
 */
@Service
@Transactional
@SuppressWarnings("all")
public class EquipmentServiceImpl extends BaseSupportImpl<Equipment> implements EquipmentService{
/*
* private Long id;
    private Float price;
    private String name;
    private Long totalNum;
    private Long leftNum;
    private Set<EquipmentDetail> equipmentDetails = new HashSet<EquipmentDetail>();
*
* */
        @Override
        public List<Equipment> getByCondition(Equipment equipment) {
            String sql = "from Equipment e where 1=1 ";
            if (equipment.getId()!=null)
                sql += " and e.id ="+equipment.getId();
            if (equipment.getName()!=null)
                sql += " and e.name = '"+equipment.getName()+"'";
            System.out.println(sql+"=========这是sql语句==========");
            return getSession().createQuery(sql).list();

        }
}
